package com.api.department.deletemember;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IDepartmentApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = "classpath:/department/department-members.xml")
public class DeleteMember extends AbstractApiTest {

	@Value("#{department_toAddMember[owner].appId}")
	private String userUrn;

	@Value("#{department_toAddMember[owner].password}")
	private String userPassword;

	@Value("#{department_toAddMember.urn}")
	private String iddepartment;

	@Value("#{department_toAddMember[member].appId}")
	private String idUserToRemove;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void test() throws ZyncroApiException {
		getApi().getService(IDepartmentApiService.class).deleteMember(iddepartment, idUserToRemove);
	}

	@AfterClass
	public void restoreValues() throws ZyncroApiException {

		boolean isOwner = false;

		getApi().getService(IDepartmentApiService.class).addMember(iddepartment, idUserToRemove, isOwner);
	}
}
